package cn.piesat.scanning.business.xz.service.impl;

import cn.piesat.scanning.business.xz.service.BuildAlgorithmTaskService;
import cn.piesat.scanning.business.xz.single.AlgorithmTaskPathParam;
import cn.piesat.scanning.business.xz.single.AlgorithmTaskRuleParam;
import cn.piesat.scanning.dto.HtScanningMetadataDTO;
import cn.piesat.scanning.service.HtScanningMetadataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Ming
 * @version 1.0
 * @description: TODO
 * @date 2023/12/18 13:48
 */
@Service
public class BuildHB_LSTServiceImpl implements BuildAlgorithmTaskService {
    @Autowired
    private HtScanningMetadataService htScanningMetadataService;
    @Override
    public Map<String, Object> initAlgorithmParams(String adsType, String primaryFile, String filePath, AlgorithmTaskRuleParam taskRuleParam,
                                                   AlgorithmTaskPathParam taskPathParam, Map<String, Integer> indexParams, String fileDate,
                                                   String scanningPath,HtScanningMetadataDTO htScanningMetadataDTO) {
        Map<String, Object> algorithmParams = new HashMap<>();
        //卫星陆表温度产品反演 LST
        Map<String, Object> params = new HashMap<>();
        params.put("primaryFile", primaryFile);
        HtScanningMetadataDTO metadataDTO = htScanningMetadataService.findMetaDataDto(fileDate, "L2", taskPathParam.getParameter07(),
                "CLM", "GBAL", "NC", "BAS");
        if (null == metadataDTO) {
            algorithmParams.put("parameter01", null);
        } else {
            params.put("auxPath", taskPathParam.getParameter03());
            params.put("DayOrNight", htScanningMetadataDTO.getObsMode());
            params.put("satelliteName", taskPathParam.getParameter07());
            params.put("L2File", taskPathParam.getParameter02() + metadataDTO.getFilePath());
            algorithmParams.put("parameter00", adsType);
            algorithmParams.put("parameter01", params);
        }
        return algorithmParams;
    }
}
